package projecteuler;

import java.util.ArrayList;

public class Problem30
{
    public static void main(String[] args)
    {
        ArrayList<ArrayList<String>> allPower5Numbers = new ArrayList<ArrayList<String>>();
        int sum = 0;
        int numTest = 0;
        while (numTest >= sum)
        {
            sum = 0;
            numTest++;
            ArrayList<String> currentNum = new ArrayList<String>();
            String tempNum = String.valueOf(numTest);
            for (int j = tempNum.length() - 1; j >=0 ; j--)
            {
                currentNum.add(String.valueOf(tempNum.charAt(j)));
            }
            for (String s : currentNum)
            {
                ArrayList<String> currentDigit = new ArrayList<String>();
                currentDigit.add(s);
                ArrayList<String> poweredTo5 = Utils.power(currentDigit, 5);
                String poweredTo5Str = "";
                for (String dig : poweredTo5)
                {
                    poweredTo5Str = dig+poweredTo5Str;
                }
                sum += Integer.parseInt(poweredTo5Str);
            }
            if (sum == numTest)
            {
                allPower5Numbers.add(currentNum);
            }
        }
    }
}
